namespace CookieTerm.MdiTabStrip
{

    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.Data;
    using System.Diagnostics;
    using System.Drawing;
    using System.Windows.Forms;

    [System.ComponentModel.ToolboxItem(false)]
    internal class MdiTabStripDropDown : ContextMenuStrip
    {

        internal MdiTabStripDropDown()
            : base()
        {

            this.Renderer = new MdiMenuStripRenderer();
        }

        internal void SetItemChecked(MdiMenuItem item)
        {
            foreach (MdiMenuItem mi in this.Items)
            {
                mi.Checked = false;
            }

            item.Checked = true;
        }

        protected override void OnItemAdded(ToolStripItemEventArgs e)
        {
            base.OnItemAdded(e);
            this.SetItemChecked((MdiMenuItem)e.Item);
        }
    }

    internal class MdiMenuItem : ToolStripMenuItem
    {

        private bool m_isMouseOver = false;

        private MdiTab m_ownerTab;
        public MdiMenuItem(MdiTab tab, EventHandler handler)
        {
            this.m_ownerTab = tab;
            this.Click += handler;
        }

        public Form Form
        {
            get { return this.m_ownerTab.Form; }
        }

        public bool IsMouseOver
        {
            get { return this.m_isMouseOver; }
        }

        public bool IsTabActive
        {
            get { return this.m_ownerTab.IsActive; }
        }

        public bool IsTabVisible
        {
            get { return this.m_ownerTab.Visible; }
        }

        protected override void OnMouseEnter(System.EventArgs e)
        {
            base.OnMouseEnter(e);
            this.m_isMouseOver = true;
            this.Invalidate();
        }

        protected override void OnMouseLeave(System.EventArgs e)
        {
            base.OnMouseLeave(e);
            this.m_isMouseOver = false;
            this.Invalidate();
        }
    }
    //=======================================================
    //Service provided by Telerik (www.telerik.com)
    //Conversion powered by NRefactory.
    //Twitter: @telerik
    //Facebook: facebook.com/telerik
    //=======================================================
}